<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增交易量奖励配置')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-transactionReward-edit" th:object="${transactionReward}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">活动编号：</label>
            <div class="col-sm-8">
                <input name="actId" id="actId" readonly th:field="*{actId}" type="text" class="form-control" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">活动名称：</label>
            <div class="col-sm-8">
                <input name="actName" id="actName" th:field="*{actName}" onclick="selectRewardActive()" readonly  type="text" class="form-control" required>
                <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label  is-required">服务商编号：</label>
            <div class="col-sm-8">
                <input name="agentNum"  readonly id="xagentNum" th:field="*{agentNum}" type="text" class="form-control" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">服务商名称：</label>
            <div class="col-sm-8">
                <input name="agentName" onclick="selectAgent()" th:field="*{agentName}" class="form-control" id="xagentName" type="text" required readonly>
                <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">奖励类型：</label>
            <div class="col-sm-8">
                <select onchange="showChange(this)" name="type" class="form-control m-b" th:with="type=${@dict.getType('pay_award_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                </select>
            </div>
        </div>

        <div class="form-group" id="posShow" style="display: none">
            <label class="col-sm-3 control-label">终端数考核月标准：</label>
            <div class="col-sm-8">
                <input name="terminalStandard" th:field="*{terminalStandard}" class="form-control" placeholder="请输入终端数量" type="text">
            </div>
        </div>
        <div class="form-group" id="payShow">
            <label class="col-sm-3 control-label">月交易量返现比率：</label>
            <div class="col-sm-8">
                <input name="cashbackRatio" th:field="*{cashbackRatio}" class="form-control" placeholder="请输入奖励比例" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">奖励状态：</label>
            <div class="col-sm-8">
                <select name="status" class="form-control m-b" th:with="type=${@dict.getType('pay_award_status')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">交易量考核月标准 ：</label>
            <div class="col-sm-8">
                <input name="tradingStandard" th:field="*{tradingStandard}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "transactionReward"
    $("#form-transactionReward-edit").validate({
        focusCleanup: true
    });

    $("input[name='date']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-transactionReward-edit').serialize());
        }
    }

    $("input[name='updateDateTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='createDateTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    function showChange(obj) {
        if (obj.value == '2'){
            $("#posShow").show();
            $("#payShow").hide();
        } else {
            $("#posShow").hide();
            $("#payShow").show();
        }
    }

    function selectRewardActive() {
        var url =prefix+ "/selectRewardActive";
        $.modal.open("选择活动" , url, '1000',"600");
    }
</script>
</body>
</html>